/*
 * Prostokat.cpp
 *
 * Version: $Id: Prostokat.cpp 71 2011-12-10 07:54:45Z s8376@pjwstk.edu.pl $
 */
#include <string.h>
#include "Punkt.h"
#include "Prostokat.h"

using namespace std;

PROSTOKAT::PROSTOKAT(char* name, PUNKT p1, PUNKT p2) :
    m_name(name), m_topLeft(p1), m_bottomRight(p2)
{
}
PROSTOKAT::PROSTOKAT(const PROSTOKAT& ob) :
    m_name(strdup(ob.m_name)), m_topLeft(ob.m_topLeft),
            m_bottomRight(ob.m_bottomRight)
{
}
PROSTOKAT::~PROSTOKAT()
{
    //    delete[] m_name;
    //    m_name = 0;
}
int PROSTOKAT::getArea()
{
    double height, width;

    width = m_topLeft.getX() - m_bottomRight.getX();
    if (width < 0) {
        width = width * -1;
    }

    height = m_topLeft.getY() - m_bottomRight.getY();
    if (height < 0) {
        height = height * -1;
    }

    return (int) width * height;
}
char* PROSTOKAT::getName()
{
    return m_name;
}
void PROSTOKAT::show()
{
    m_topLeft.show();
    m_bottomRight.show();
}
